var vm = new Vue({
	el: '#list',
	data: {
		arrow:'./img/arrow-156.png',
		keyWord:"",
		isActive: false,
		logPopupStatus: false,
		buttons: Array(15).fill(null),
		activeButton: {},
		dataSummary:[],
		filteredArr:[],
		menu:[],
		total:[]
	},
	mounted(){
		this.wallpaperMethod()
	},
	methods: {
		wallpaperMethod(){
			this.menu = menu2
			this.total = total3.concat(total, total2);
			if( window.innerHeight < 800 ){
				let dom = document.querySelector('.generalNavigation')
				dom.classList.add('on')
			}
		},
		jump(base64String){
			var keyword = "http";
			if (base64String.includes(keyword)) {
				window.open(base64String)
			} else {
				let result = base64String.replace(/%3D/g, "");
				let decodedString = atob(result);
				window.open(decodedString)
			}
		},
		handleClick(element,indexTotal,index){
			this.total[indexTotal].identification = index
			const siblings = element.parentNode.querySelectorAll('a');
			siblings.forEach(sibling => {
				sibling.classList.remove('active');
			});
			element.classList.add('active');
		},
		//检索
		retrieval(){
			let _this = this
			if( this.keyWord == "" ){
				swal("请输入搜索网址关键字！")
				_this.filteredArr = []
				return false
			}
			_this.filteredArr = []
			_this.dataSummary = []
			for (let i = 0; i < _this.total.length; i++) {
			  this.conversion(_this.total[i].data);
			}
			let filterArr = _this.dataSummary.filter(item => item.title.toLowerCase().includes(_this.keyWord.toLowerCase()));
			// 先去重，再赋值
			_this.filteredArr = Array.from(new Set(filterArr.map(obj => obj.title))).map(title => {
				return filterArr.find(obj => obj.title === title);
			});
		},
		// 数组转化
		conversion(array){
			let _this = this
			array.forEach(function(currentValue, index, array1) {
				currentValue.icon.forEach(function(currentValue2, index2, array2) {
					_this.dataSummary.push({
						icon:currentValue.icon[index2],
						title:currentValue.title[index2],
						describe:currentValue.describe[index2],
						href:currentValue.href[index2],
					})
				})
			});
		},
		// 日志弹窗
		logPopupMethods(){
			this.logPopupStatus = true
		},
		// 平滑滚动至页面顶部
		scrollToTop() {
			var input = document.getElementById("myInput");
			input.focus();
			// 设置CSS的scroll-behavior属性为smooth，实现平滑滚动
			document.documentElement.style.scrollBehavior = 'smooth';
			// 使用scrollTo()方法将页面滚动至顶部
			window.scrollTo({
				top: 0,
				behavior: 'smooth'
			});
			// 恢复CSS的scroll-behavior属性为默认值
			setTimeout(function() {
				document.documentElement.style.scrollBehavior = 'auto';
			}, 1000);
		}
	}
})
